티스토리 뷰

mysql 5.7 버전에서 8.0으로 변경시 버전변경으로 인한 구문오류가 생겼다.

메이저 버전이 바뀐 만큼 다양한 변경사항이 있겠지만 그 중에서 sql 구문오류가 생겨 처리하는 방법을 찾아봤다.

 

쿼리 중 alias로 except 를 사용하였으나, 8버전 부터 키워드로 지정된 듯하다. 

자세한 변경사항은 아래를 참조하자

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html

 

MySQL :: MySQL 8.0 Reference Manual :: 2.11.4 Changes in MySQL 8.0

2.11.4 Changes in MySQL 8.0 Before upgrading to MySQL 8.0, review the changes described in this section to identify those that apply to your current MySQL installation and applications. Perform any recommended actions. Changes marked as Incompatible chang

dev.mysql.com

5.7에서 8.0으로 변경사항 중 키워드와 예약어가 추가되었다고 한다.

Some keywords may be reserved in MySQL 8.0 that were not reserved in MySQL 5.7. See Section 9.3, “Keywords and Reserved Words”. This can cause words previously used as identifiers to become illegal. To fix affected statements, use identifier quoting. See Section 9.2, “Schema Object Names”.

 

추가된 내용 중 except 가 추가된 것을 볼 수 있다. ㅠㅠ

  • EVENT

  • EVENTS

  • EVERY

  • EXCEPT (R)

  • EXCHANGE

  • EXCLUDE; added in 8.0.2 (nonreserved)

 

처리 방법은 다양한게 있겠지만 대충 살펴보면

1. alias를 다른 명칭으로 바꾼다. 

이 경우 관련된 소스를 전부 변경해줘야한다. 사용하는 곳이 적다면 어차피 추가된 키워드 혹은 예약어 이기 때문에 이 방법이 최선.

 

2. mysql 8.0을 사용하지 말고 5.7로 유지한다.

구지 올려야될 이슈가 없다면 그냥 유지하자. 하지만 성능면에서나 보안적인 이슈로 최신을 사용하는 것이 권장하겠지?

 

3. 키워드 혹은 예약어를 식별자(`)로 처리한다.

select * from order

the error rises:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1
Reserved keywords in MySQL need to be escaped with backticks (`)

 

예약어를 역따옴표로 묶어 식별자로 처리하였다.

select * from `order`

 

 

https://sodocumentation.net/mysql/topic/1398/reserved-words

 

MySQL - Reserved Words | mysql Tutorial

mysql documentation: Reserved Words

sodocumentation.net

 

'공부합시다' 카테고리의 다른 글

keystore 에서 pem 변경하기  (0) 2020.11.18
macOS JAVA 설치하기  (0) 2020.11.18
next.js HOST, PORT 설정하기  (0) 2020.09.09
HTTPie  (0) 2020.06.25
curl POST 예제  (0) 2020.02.07
댓글